<?php

/*

  Action	$2

  +1 Card; +1 Action
  Look at the bottom card of your deck. You may put it on top.

 */

class PearlDiver extends Card implements iAction, iKingdom, iSeaside {

    public function __construct() {
        parent::__construct("Pearl Diver", 2);
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            "+1 Card",
            "+1 Action",
            "Look at the bottom card of your deck. You may put it on top.");
    }
    
    public function play(Game $game, $isRealCard) {
        $game->addActions(1);
        $drawed_cards = $game->drawCards(1);
         ScreenDisplay::addScreenMessage($game, true, "get +1 action  and draw " . nicePrint($drawed_cards), "gets +1 action and  draws " . sizeof($drawed_cards) . " cards");

        $card = $game->removeBottomDrawDeckCard();
        if ($card) {

             ScreenDisplay::addScreenMessage($game, true, "peek on " . nicePrint($card), "peek on 1 card");

            $options = array(new Option(1, "Yes"), new Option(2, "No"));
            $output = MySocket::GetUserReply($game, Input_ChooseOne, $options, 1, 1, null, "Move " . $card->getValue() . " to top of your deck?");

            $answer = $output[0];
            if ($answer == "Yes") {
                $game->putCardOnTopOfDrawDeck($card);
                 ScreenDisplay::addScreenMessage($game, false, " and put it on top of your deck ", " and puts it on top of his deck");
            } else {
                $game->putCardOnBottomOfDrawDeck($card);
                 ScreenDisplay::addScreenMessage($game, false, " and leave it at the bottom of your deck ", " and leaves it at the bottom of his deck");
            }
        }
        $game->cardActionFinished();
        return true;
    }

}

?>